package com.wyy.controller;

import com.wyy.pojo.Articles;
import com.wyy.pojo.LikeArticle;
import com.wyy.pojo.model.ArticleQueryCriteria;
import com.wyy.pojo.model.LabelSearch;
import com.wyy.response.CommonReturnType;
import com.wyy.web.ArticleFeignAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: gytcb
 * @author: 吴磊
 * @create: 2021-06-04 12:00
 */
@RestController
public class ArticleController {
    @Autowired
    private ArticleFeignAction articleFeignAction;

    /**
     * 获取热门的文章标签
     *
     * @return
     */
    @RequestMapping(value = "/getHotArticleLabel", method = RequestMethod.POST)
    public CommonReturnType getHotArticleLabel() {
        return articleFeignAction.getHotArticleLabel();
    }


    /**
     * 根据内容模糊查询文章
     *
     * @param articles
     * @return
     */
    @RequestMapping(value = "/getArticleByArticleContentLikeSearch", method = RequestMethod.POST)
    public CommonReturnType getArticleByArticleContentLikeSearch(@RequestBody Articles articles) {
        return articleFeignAction.getArticleByArticleContentLikeSearch(articles);
    }

    /**
     * 根据文章Id查询文章
     *
     * @param articles
     * @return
     */
    @RequestMapping(value = "/getArticleByArticleId", method = RequestMethod.POST)
    public CommonReturnType getArticleByArticleId(@RequestBody Articles articles) {
        return articleFeignAction.getArticleByArticleId(articles);
    }


    /**
     * 用户发布文章
     *
     * @param articles
     * @return
     */
    @RequestMapping(value = "/insertArticle", method = RequestMethod.POST)
    public CommonReturnType tokenInsertArticle(@RequestBody Articles articles) {
        return articleFeignAction.tokenInsertArticle(articles);
    }

    /**
     * 通过文章Id删除文章及其一切相关
     *
     * @param articleId
     * @return
     */
    @RequestMapping(value = "/deleteArticleByArticleId", method = RequestMethod.POST)
    public CommonReturnType tokenDeleteArticleByArticleId(@RequestBody String articleId) {
        return articleFeignAction.tokenDeleteArticleByArticleId(articleId);
    }

    /**
     * 编辑帖子
     *
     * @param articles
     * @return
     */
    @RequestMapping(value = "/updateArticle", method = RequestMethod.POST)
    public CommonReturnType tokenUpdateArticle(@RequestBody Articles articles) {
        return articleFeignAction.tokenUpdateArticle(articles);
    }

    /**
     * 点赞或取消点赞
     *
     * @param likeArticle
     * @return
     */
    @RequestMapping(value = "/likeArticle", method = RequestMethod.POST)
    public CommonReturnType tokenLikeOrCancelLikeArticle(@RequestBody LikeArticle likeArticle) {
        return articleFeignAction.tokenLikeOrCancelLikeArticle(likeArticle);
    }

    /**
     * 通过一些条件获取帖子
     *
     * @return
     */
    @RequestMapping(value = "/getArticleBySomething", method = RequestMethod.POST)
    public CommonReturnType getArticleBySomething(@RequestBody ArticleQueryCriteria articleQueryCriteria) {
        return articleFeignAction.getArticleBySomething(articleQueryCriteria);
    }

    /**
     * 通过文章标签模糊查询文章
     *
     * @param labelSearch
     * @return
     */
    @RequestMapping(value = "/getArticleBySearchLabel", method = RequestMethod.POST)
    public CommonReturnType getArticleBySearchLabel(@RequestBody LabelSearch labelSearch) {
        return articleFeignAction.getArticleBySearchLabel(labelSearch);
    }
}
